import { config } from 'dotenv'
import { defineConfig, devices } from '@playwright/test'

config({ path: '.env.e2e' })

export default defineConfig({
  testDir: './e2e',
  outputDir: 'playwright/result',
  reporter: [['html', { outputFolder: 'playwright/report' }]],
  timeout: 10_000,

  use: {
    baseURL: process.env.E2E_SERVER_URL,
    trace: 'on-first-retry'
  },

  expect: {
    timeout: 5000,
    toHaveScreenshot: { maxDiffPixels: 10 },
    toMatchSnapshot: { maxDiffPixelRatio: 0.1 }
  },

  fullyParallel: true,
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 2 : 0,
  workers: process.env.CI ? 1 : undefined,

  projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }]
})
